package com.example.administrator.fangbook.HtlMvp.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;

import com.example.administrator.fangbook.base.BaseActivity;

import butterknife.ButterKnife;

/**
 * Created by Administrator on 2018/11/9.
 */

public abstract class BaseMvpActivity<V extends BaseMvpView, P extends BaseMvpPresenter>
        extends BaseActivity {
    private V mMvpView;
    private P mMvpPresenter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        this.mMvpView = bindMvpView();
        if (this.mMvpPresenter == null) {
            this.mMvpPresenter = bindMvpPresenter();
        }
        this.mMvpPresenter.attachView(mMvpView);
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void onDestroy() {
        this.mMvpPresenter.destroyView();
        this.mMvpPresenter = null;
        super.onDestroy();
    }

    public abstract P bindMvpPresenter();

    public abstract V bindMvpView();

    public P getmMvpPresenter() {
        return mMvpPresenter;
    }
}
